//
//  ButtonCustom.swift
//  GOFM
//
//  Created by siri on 2024/1/5.
//  Copyright © 2024 Glad. All rights reserved.
//

import SwiftUI

struct ButtonCustom: View {
    let type:ButtonTypeEnum
    let size:ButtonSizeEnum
    let label:String
    let action: () -> Void
    
    init(type: ButtonTypeEnum = .primary, size: ButtonSizeEnum = .large, icon: String = "", label: String,  action: @escaping () -> Void) {
        self.type = type
        self.size = size
        self.label = label
        self.action = action
    }
    
    var body: some View {
        Button {
            action()
        } label: {
            if type == .character {
                Text(label)
            }else {
                Text(label)
                    .frame(width: ButtonStyleSet.buttonSize[size]!.width,height: ButtonStyleSet.buttonSize[size]!.height)
                    .padding(ButtonStyleSet.buttonSize[size]!.edgeInsets)
            }
            
        }
        .buttonStyle(ButtonCustomStyle(buttonSize: size,buttonType: type))
    }
}
